/*
 *  Copyright (C) 2011  social-tourist.org
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

package org.socialtourist.web.client.widgets;

import org.socialtourist.web.client.presenter.ProjectNeedsPresenter;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.safehtml.shared.SafeHtml;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;



public class MailAndFileWidget extends Composite implements ClickHandler {

	
	private Button sendButton;
	private VerticalPanel panel;
	private ProjectNeedsPresenter presenter;
	TextBox email;
	
	public MailAndFileWidget(ProjectNeedsPresenter presenter) {
		this.presenter = presenter;

		panel = new VerticalPanel();
		HorizontalPanel subPanel = new HorizontalPanel();
		
		subPanel.add(new Label("E-Mail Adresse"));

		email = new TextBox();
		subPanel.add(email);
		panel.add(subPanel);
	
		SafeHtmlBuilder builder = new SafeHtmlBuilder();
		builder.appendEscaped("Ich m");
		builder.appendHtmlConstant("&ouml;");
		builder.appendEscaped("chte die oben selektierten Waren spenden,"); 
		builder.appendHtmlConstant("</br>");
		builder.appendEscaped("akzeptiere die LINKZUDATENSCHUTZ-Bedingungen");
		
		subPanel = new HorizontalPanel();
		CheckBox checkbox = new CheckBox();
		Label label = new HTML(builder.toSafeHtml());
		subPanel.add(checkbox);
		subPanel.add(label);
		panel.add(subPanel);
		
		sendButton = new Button("Donate");
		sendButton.addClickHandler(this);
		panel.add(sendButton);
		
		
		initWidget(panel);
	}

	@Override
	public void onClick(ClickEvent event) 
	{
		presenter.mfDonateButtonClicked();		
	}

	public String getTextEmail() {
		return email.getText();
	}
}
